package com.qk.mapper;

import com.qk.entity.Activity;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper

public interface ActivityMapper {
    @Delete("Delete from activity where id = #{id}")
    void deleteById(Integer id);
@Insert("INSERT INTO activity(channel, name, start_time, end_time, description, type, discount, voucher, create_time, update_time) VALUES(#{channel}, #{name}, #{startTime}, #{endTime}, #{description}, #{type}, #{discount}, #{voucher}, #{createTime}, #{updateTime})")
    void insert(Activity activity);
@Select("Select id, channel, name, start_time, end_time, description, type, discount, voucher, create_time, update_time from activity where id = #{id}")
    Activity getById(Integer id);
@Insert( "UPDATE activity SET channel = #{channel}, name = #{name}, start_time = #{startTime}, end_time = #{endTime}, description = #{description}, type = #{type}, discount = #{discount}, voucher = #{voucher}, update_time = #{updateTime} WHERE id = #{id}")
    void update(Activity activity);
@Select("Select id, channel, name, start_time, end_time, description, type, discount, voucher, create_time, update_time from activity where type = #{type}")
    List<Activity> listByType(Integer type);


    List<Activity> listActivity(Integer channel, Integer type, Integer status);
}
